/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.web.tsfile.core.service;

import com.inspur.edp.web.tsfile.api.service.TsFileService;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TsFileServiceImplTest {

    @Test
    public void testClassName() {
        TsFileService tsFileService = new TsFileServiceImpl();
        String tsClassName = tsFileService.getTsClassNameByPath("ddd.ts");
        System.out.printf(tsClassName);
    }

    @Test
    public void replaceTsClassName() {
        TsFileService tsFileService = new TsFileServiceImpl();
        String oldTsClassName = tsFileService.getTsClassNameByPath("ddd.ts");
        assertEquals(oldTsClassName, "DddService");

        String content = "export class DddService {}";
        String newTsClassName = tsFileService.getTsClassNameByPath("mmm.ts");
        content = content.replace(oldTsClassName, newTsClassName);
        assertEquals(content, "export class MmmService {}");
    }
}